<?php
/**
 * @package admin
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: template_select.php 6131 2007-04-08 06:56:51Z drbyte $
 */

  require('includes/application_top.php');


  if(isset($_GET['action']) && trim($_GET['action']) == 'copy'){

// print_r($_GET);
// die();

// class smz {
//
//   var $mod=array();
//
//
//   function all_file_system($directory, $regex=false) {
//     $array_items = array();
//     if ($handle = @opendir($directory)) {
//       while (false !== ($tmpfile = readdir($handle))) {
// 	if ($tmpfile != "." && $tmpfile != "..") {
// 	  if (is_dir($directory. "/" . $tmpfile)) {
// 	    $array_items = array_merge($array_items, $this->all_file_system($directory. "/" . $tmpfile, $regex));
// 	    $tmpfile = $directory . "/" . $tmpfile;
// 	    $array_items[] = preg_replace("/\/+/si", "/", $tmpfile);
// 	  } else {
// 	    $tmpfile = $directory . "/" . $tmpfile;
// 	    $array_items[] = preg_replace("/\/+/si", "/", $tmpfile);
// 	  }
// 	}
//       }
// 	closedir($handle);
//       }
//       unset($handle);
//       unset($tmpfile);
//       if($regex){
// 	foreach($array_items as $key=>$val){
// 	  if(!preg_match('/'.$regex.'/',$val)){
// 	    unset($array_items[$key]);
// 	  }
// 	}
//       }
//       return $array_items;
//   }
//
//
//   function writeable_directories($directory, $regex='') {
//     $array_items = array();
//     if ($handle = @opendir($directory)) {
//       while (false !== ($tmpfile = readdir($handle))) {
// 	if ($tmpfile != "." && $tmpfile != "..") {
// 	  if (is_dir($directory. "/" . $tmpfile)) {
// 	    $array_items = array_merge($array_items, $this->writeable_directories($directory. "/" . $tmpfile, $regex));
// 	    $tmpfile = $directory . "/" . $tmpfile;
// 	    $array_items[] = preg_replace("/\/+/si", "/", $tmpfile);
// 	  }
// /*else {
// 	    $tmpfile = $directory . "/" . $tmpfile;
// 	    $array_items[] = preg_replace("/\/+/si", "/", $tmpfile);
// 	  }*/
// 	}
//       }
// 	closedir($handle);
//       }
//       unset($handle);
//       unset($tmpfile);
// //       if($regex !=''){
// 	foreach($array_items as $key=>$val){
// // 	    print $val.'<br />';
// 	  if(!is_writeable($val)){
// 	    unset($array_items[$key]);
// 	  }
// 	}
// //       }
//       return $array_items;
//   }
//
//   function advise_deletion($items = array()){
//
//     foreach($items as $key=>$val){
//       $remove = preg_replace('/\/+/', '/', DIR_FS_CATALOG.$val);
//       if(file_exists($remove)){
// 	print '<li>'.$remove.' (still exists)</li>';
//       }else{
// 	print '<li>'.$remove.' (not found)</li>';
//       }
//     }
//
//   }
//
//   function load_modules(){
//
//     $dir = DIR_FS_SMZ;
//
//     if (is_dir($dir)) {
//       if ($dh = opendir($dir)) {
// 	  while (($file = readdir($dh)) !== false) {
// 	    if( !in_array($file, array('.', '..', '.htaccess')) && is_file($dir.$file)){
// 	      $tmp = file($dir.$file);
// // 	      print $file.'<br />';
// 	      $this->mod[(int)$tmp[1]] = array( 'title'=>trim($tmp[2]), 'switch'=>trim($tmp[1]), 'long_title'=>trim($tmp[3]), 'filename'=>$dir.$file );
// 	    }
// 	  }
// 	  closedir($dh);
//       }
//     }
//     unset($tmp);
//
//     ksort($this->mod);
//
//   }
//
//   function getPage($page=''){
//
//     global $pl;
//
//     if(trim($page)=='' || trim($this->mod[(int)$page]['filename'])=='' || !file_exists($this->mod[(int)$page]['filename'])){
//       $page = 0;
//     }
// //       print_r($this->mod[0]);
//     if(file_exists($this->mod[(int)$page]['filename'])){
//       include($this->mod[(int)$page]['filename']);
//     }else{
//       print "<p><strong>".$this->mod[(int)$page]['filename']."</strong> not found</p>";
//     }
//
//     return true;
//
//   }
//
//
//
// }

  $tmp = new smz_filesystem;

    $from = basename($_POST['copy']);

//     $from = 'classic';

    function prepend_fs(&$item1, $key){
	$item1 = DIR_FS_CATALOG.$item1;
    }

    function template_exists($val){
      return file_exists($val);
    }

    $possible_dirs = array('includes/templates/'.$from, 'includes/modules/'.$from, 'includes/modules/sideboxes/'.$from);

    array_walk($possible_dirs, 'prepend_fs');

    $possible_dirs = array_merge($possible_dirs, $tmp->all_file_system(DIR_FS_CATALOG.'includes/languages', $from.'$') );

    $possible_dirs = array_filter($possible_dirs, 'template_exists');




//   $fc = new smz_filesystem;

  $target = basename($_POST['tx']);
  $execute = true ;
  foreach($possible_dirs as $dir){
    $tmp_dir = dirname($dir);
    $fc->stat($tmp_dir);
    if($fc->dnw){
      $messageStack->add_session( '<em>'.$tmp_dir.'</em> is not writeable, (or able to be unlocked by the webserver).', 'error');
      $execute = false;
    }
    if(file_exists($tmp_dir.'/'.$target)){
      $messageStack->add_session( '<em>'.$tmp_dir.'/'.$target.'</em> already exists.', 'error');
      $execute = false;
    }
  }

  if($execute){

    foreach($possible_dirs as $dir){
      $tmp_dir = dirname($dir);
      $fc->unlock(dirname($tmp_dir.'/'.$target));
      $fc->smartCopy($dir, $tmp_dir.'/'.$target);
      $fc->relockRecursive($tmp_dir.'/'.$target);
      // need a recursive lock feature, new subfolders are copied with 755
    }

    $sit = trim(preg_replace('/\?>$/', '', trim(file_get_contents(DIR_FS_CATALOG.'includes/templates/'.$from.'/template_info.php'))));

    foreach(array('name', 'version', 'author', 'description') as $line){
      $sit .= "\r\n\$template_$line = '".str_replace("'", '\'', $_POST[$line])."';";
    }

    $template_info_file = DIR_FS_CATALOG.'includes/templates/'.$target.'/template_info.php' ;
    $fc->unlock($template_info_file);
    file_put_contents($template_info_file, $sit);
    $fc->relock($template_info_file);
    $messageStack->add_session('<strong>'.$target.'</strong> created, new <em>\''.str_replace("'", '\'', $_POST['name']).'\'</em> template available.<br />&quot;Tools &gt;&gt; Layout Boxes controller&quot; needs visiting after assigning the new template, to reset the sideboxes so they display on the shop (as with any other new template).', 'success');
    header('Location: '.zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $_GET['tID']));
    exit;
  } // end of if execute

  header('Location: '.zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=dupe&tID=' . $_GET['tID']));
  exit;


  }


//
//	END
//	OF
//	POST
//






// get an array of template info
  $dir = @dir(DIR_FS_CATALOG_TEMPLATES);
  if (!$dir) die('DIR_FS_CATALOG_TEMPLATES NOT SET');
  while ($file = $dir->read()) {
    if (is_dir(DIR_FS_CATALOG_TEMPLATES . $file) && strtoupper($file) != 'CVS' && $file != 'template_default') {
      if (file_exists(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php')) {
        require(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php');
        $template_info[$file] = array('name' => $template_name,
                                      'version' => $template_version,
                                      'author' => $template_author,
                                      'description' => $template_description,
                                      'screenshot' => $template_screenshot);
      }
    }
  }
  $dir->close();

  $action = (isset($_GET['action']) ? $_GET['action'] : '');

  if (zen_not_null($action)) {
    switch ($action) {
      case 'insert':
        $check_query = $db->Execute("select * from " . TABLE_TEMPLATE_SELECT . " where template_language = '" . $_POST['lang'] . "'");
        if ($check_query->RecordCount() < 1 ) {
          $db->Execute("insert into " . TABLE_TEMPLATE_SELECT . " (template_dir, template_language) values ('" . $_POST['ln'] . "', '" . $_POST['lang'] . "')");
          $_GET['tID'] = $db->Insert_ID();
        }
        $action="";
        break;
      case 'save':
        $db->Execute("update " . TABLE_TEMPLATE_SELECT . " set template_dir = '" . $_POST['ln'] . "' where template_id = '" . $_GET['tID'] . "'");
        break;
      case 'deleteconfirm':
        $check_query = $db->Execute("select template_language from " . TABLE_TEMPLATE_SELECT . " where template_id = '" . $_GET['tID'] . "'");
        if ( $check_query->fields['template_language'] != 0 ) {
          $db->Execute("delete from " . TABLE_TEMPLATE_SELECT . " where template_id = '" . $_GET['tID'] . "'");
          zen_redirect(zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page']));
        }
        $action="";
        break;
    }
  }
  $template_selected = '';
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
  <!--
  function defaultClear(itm){
    if( itm.value.trim() == itm.defaultValue.trim() ){
      itm.value = '';
      itm.style.fontStyle='normal';
    }else
    if( itm.value.trim() == '' ){
      itm.value = itm.defaultValue;
      itm.style.fontStyle='italic';
    }
  }
  function init()
  {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
      var kill = document.getElementById('hoverJS');
      kill.disabled = true;
    }
  }
  // -->
</script>
</head>
<body onLoad="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
                <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                    <tr class="dataTableHeadingRow">
                      <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE; ?></td>
                      <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NAME; ?></td>
                      <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DIRECTORY; ?></td>
                      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
                    </tr>
                    <?php
  $template_query_raw = "select * from " . TABLE_TEMPLATE_SELECT;
  $template_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $template_query_raw, $template_query_numrows);
  $templates = $db->Execute($template_query_raw);
  while (!$templates->EOF) {
    if ((!isset($_GET['tID']) || (isset($_GET['tID']) && ($_GET['tID'] == $templates->fields['template_id']))) && !isset($tInfo) && (substr($action, 0, 3) != 'new')) {
      $tInfo = new objectInfo($templates->fields);
    }

    if (isset($tInfo) && is_object($tInfo) && ($templates->fields['template_id'] == $tInfo->template_id)) {
      echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '\'">' . "\n";
    } else {
      echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $templates->fields['template_id']) . '\'">' . "\n";
    }
    if ($templates->fields['template_language'] == 0) {
      $template_language = "Default(All)";
    } else {
      $ln = $db->Execute("select name
                          from " . TABLE_LANGUAGES . "
                          where languages_id = '" . $templates->fields['template_language'] . "'");
      $template_language = $ln->fields['name'];
    }
?>
                    <td class="dataTableContent"><?php echo $template_language; ?></td>
                    <td class="dataTableContent"><?php echo $template_info[$templates->fields['template_dir']]['name']; ?></td>
                    <td class="dataTableContent" align="center"><?php echo $templates->fields['template_dir']; ?></td>
                    <td class="dataTableContent" align="right">
<?php
		    echo '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=dupe&tID=' . $templates->fields['template_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_copy_to.gif', IMAGE_COPY_TO) . '</a>';
?>&nbsp;
<?php
		    if (isset($tInfo) && is_object($tInfo) && ($templates->fields['template_id'] == $tInfo->template_id) ) {
		      echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', '');
		      $template_selected = $tInfo;
		    } else {
		      echo '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $templates->fields['template_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>';
		    }
?>
                      &nbsp;</td>
                    </tr>
<?php
    $templates->MoveNext();
  }
?>
                    <tr>
                      <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                          <tr>
                            <td class="smallText" valign="top"><?php echo $template_split->display_count($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_TEMPLATES); ?></td>
                            <td class="smallText" align="right"><?php echo $template_split->display_links($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
                          </tr>
                          <?php
  if (empty($action)) {
?>
                          <tr>
                            <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=new') . '">' . zen_image_button('button_new_language.gif', IMAGE_NEW_TEMPLATE) . '</a>'; ?></td>
                          </tr>
                          <?php
  }
?>
                        </table></td>
                    </tr>
                  </table></td>
                <?php
  $heading = array();
  $contents = array();

  switch ($action) {
    case 'new':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_TEMPLATE . '</b>');

      $contents = array('form' => zen_draw_form('zones', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=insert'));
      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
      while (list ($key, $value) = each($template_info) ) {
        $template_array[] = array('id' => $key, 'text' => $value['name']);
      }
      $lns = $db->Execute("select name, languages_id from " . TABLE_LANGUAGES);
      while (!$lns->EOF) {
        $language_array[] = array('text' => $lns->fields['name'], 'id' => $lns->fields['languages_id']);
        $lns->MoveNext();
      }
      $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_NAME . '<br>' . zen_draw_pull_down_menu('ln', $template_array));
      $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . zen_draw_pull_down_menu('lang', $language_array, $_POST['lang']));
      $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
      break;
    case 'edit':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_TEMPLATE . '</b>');

      $contents = array('form' => zen_draw_form('templateselect', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=save'));
      $contents[] = array('text' => '<br /><strong>'.TEXT_INFO_EDIT_INTRO.':</strong> ' . $template_info[$template_selected->template_dir]['name'] );
      reset($template_info);
      while (list ($key, $value) = each($template_info) ) {
        $template_array[] = array('id' => $key, 'text' => $value['name']);
      }
      $contents[] = array('text' => TEXT_INFO_TEMPLATE_NAME . '<br>' . zen_draw_pull_down_menu('ln', $template_array, $template_selected->template_dir));
      $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
      break;
    case 'delete':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_TEMPLATE . '</b>');

      $contents = array('form' => zen_draw_form('zones', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=deleteconfirm'));
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<br><b>' . $template_info[$tInfo->template_dir]['name'] . '</b>');
      $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
      break;
    case 'dupe':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TEMPLATE . '</b>');

      $contents = array('form' => zen_draw_form('templateselect', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=copy', 'post', 'onsubmit="if(this.tx.value==this.tx.defaultValue){alert(\'&quot;destination folder&quot;, is not a good name.\');return false;}"'));
      $contents[] = array('text' => '<br /><strong>'.TEXT_INFO_COPY_INTRO.':</strong> ' . $template_info[$template_selected->template_dir]['name'] );
//       reset($template_info);
//       while (list ($key, $value) = each($template_info) ) {
//         $template_array[] = array('id' => $key, 'text' => $value['name']);
//       }
// function zen_draw_hidden_field($name, $value = '', $parameters = '') {
// $template_selected->template_dir
      $contents[] = array('text' => zen_draw_hidden_field('copy', $template_selected->template_dir, '' ) );
      $contents[] = array('text' => '<label for="target">'.TEXT_INFO_TEMPLATE_NAME . '<label>'.zen_draw_input_field('tx', 'destination folder', 'onfocus="defaultClear(this)" onblur="defaultClear(this)" style="font-style: italic"') );
      $contents[] = array('text' => '(destination folder must not exist)');
      $contents[] = array('text' => zen_draw_input_field('name', 'Template name', 'onfocus="defaultClear(this)" onblur="defaultClear(this)" style="font-style: italic"') );
      $contents[] = array('text' => zen_draw_input_field('version', 'Template version', 'onfocus="defaultClear(this)" onblur="defaultClear(this)" style="font-style: italic"') );
      $contents[] = array('text' => zen_draw_input_field('author', 'Template author', 'onfocus="defaultClear(this)" onblur="defaultClear(this)" style="font-style: italic"') );
      $contents[] = array('text' => zen_draw_textarea_field('description', false, 60, 5, 'Template description', 'onfocus="defaultClear(this)" onblur="defaultClear(this)" style="font-style: italic"') );
      $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_copy_to.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
      break;
    case 'delete':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_TEMPLATE . '</b>');

      $contents = array('form' => zen_draw_form('zones', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=deleteconfirm'));
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<br><b>' . $template_info[$tInfo->template_dir]['name'] . '</b>');
      $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
      break;
    default:
      if (isset($tInfo) && is_object($tInfo)) {
        $heading[] = array('text' => '<b>' . $template_info[$tInfo->template_dir]['name'] . '</b>');
        if ($tInfo->template_language == 0) {
          $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
        } else {
          $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
        }
        $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_AUTHOR  . $template_info[$tInfo->template_dir]['author']);
        $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_VERSION  . $template_info[$tInfo->template_dir]['version']);
        $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_DESCRIPTION  . '<br />' . $template_info[$tInfo->template_dir]['description']);
        $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_INSTALLED  . '<br />');
        while (list ($key, $value) = each($template_info) ) {
          $contents[] = array('text' => '<a href="' . DIR_WS_CATALOG_TEMPLATE . $key . '/images/' . $value['screenshot'] . '" target = "_blank">' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a>&nbsp;&nbsp;' . $value['name']);
        }
      }
      break;
  }

  if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
    echo '            <td width="25%" valign="top">' . "\n";

    $box = new box;
    echo $box->infoBox($heading, $contents);

    echo '            </td>' . "\n";
  }
?>
              </tr>
            </table></td>
        </tr>
      </table></td>
    <!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
